Skip to content

Conversation

@lacatoire
Copy link
Contributor

This PR documents the ability to use PHP closures with the #[Cache] attribute
to compute the Last-Modified and ETag HTTP headers.

Closures can be used as an alternative to expressions and receive the resolved
controller arguments and the current Request object.

The documentation includes examples based on controller arguments and request
attributes, and clarifies that headers already set on the Response are not
overridden.

Issue #21678

@carsonbot carsonbot added this to the 8.1 milestone Jan 9, 2026
@lacatoire lacatoire force-pushed the document-cache-attribute-closures branch 2 times, most recently from 44785a0 to abdba3e Compare February 10, 2026 11:34
@carsonbot carsonbot changed the title [HttpCache] Document support for closures in Cache attribute [Cache][HttpCache] Document support for closures in Cache attribute Feb 12, 2026
@javiereguiluz javiereguiluz force-pushed the document-cache-attribute-closures branch from abdba3e to dce9a40 Compare February 12, 2026 11:31
@javiereguiluz javiereguiluz merged commit 9900c14 into symfony:8.1 Feb 12, 2026
3 checks passed
@javiereguiluz
Copy link
Member

Louis-Arnaud, thanks a lot for contributing this!

While merging, we moved the new content to the http_cache/validation.rst file because we added the docs for a similar feature (using expressions in #[Cache] attribute) and both complement each other well.

@lacatoire lacatoire deleted the document-cache-attribute-closures branch February 12, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants